import React from "react";
import usePublish from "./usePublish";
import NewsPublish from "../../../components/publish-manage/NewsPublish";
import {Button} from "antd";

export default function Published() {
    // const [dataSource, setDataSource] = useState([]);
    // const { username } = JSON.parse(localStorage.getItem('token'));
    // useEffect(()=>{
    //     axios.get(`/api/news?author=${username}&publishState=1&_expand=category`).then(response=>{
    //         const data= response.data;
    //         setDataSource(data)
    //     });
    // }, [username]);

    // 使用自定义的Hooks
    const { dataSource, handleSunset }= usePublish(1)  // 1已发布

    return (
        <div>
            <NewsPublish dataSource={ dataSource } button={(id)=><Button danger onClick={()=>handleSunset(id)}>下线</Button>}/>
        </div>
    );
}
